using System;

namespace Wizard.Runtime
{
    // not used
    public class EvalVariable : IHasValue
    {
        private readonly Type mSystemType;
        private object mValue;

        #region "IHasValue implementation"

        public Type SystemType
        {
            get { return mSystemType; }
        }

        Type IHasValue.ValueType
        {
            get { return SystemType; }
        }


        public event ValueChangedEvent ValueChanged;

        #endregion

        public EvalVariable(object originalValue, Type systemType)
        {
            mValue = originalValue;
            if (systemType == null)
                if (originalValue == null)
                    throw new Exception("Cannot establish runtime type on variable <nothing>.");
                else
                    mSystemType = originalValue.GetType();
            else
                mSystemType = systemType;
        }

        public object Value
        {
            get { return mValue; }
            set
            {
                if (value != mValue)
                {
                    mValue = value;
                }
            }
        }




        #region IHasValue Members



        event ValueChangedEvent IHasValue.ValueChanged
        {
            add { throw new NotImplementedException(); }
            remove { throw new NotImplementedException(); }
        }

        #endregion

        #region IHasValue Members


        public object GetValueObject(IRunContext context)
        {
            return mValue;
        }

        #endregion

        #region IHasValue Members


        object IHasValue.GetValueObject(IRunContext context)
        {
            throw new NotImplementedException();
        }

        #endregion
    }
}